<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="投票名称" prop="voteName">
        <el-input v-model="queryParams.voteName" placeholder="请输入投票名称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                   v-hasPermi="['vote:info:create']">新增</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
                   v-hasPermi="['vote:info:export']">导出</el-button>
      </el-col> -->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
      <el-table-column label="投票名称" align="center" prop="voteName" />
      <!-- <el-table-column label="规则类型" align="center" prop="voteType" >
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.VOTE_RULE_TYPE" :value="scope.row.voteType"/>
        </template>
      </el-table-column> -->

      <el-table-column label="投票开始时间" align="center" prop="beginTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.beginTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="投票结束时间" align="center" prop="endTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center">
         <template slot-scope="scope">
           <el-tag type="info" v-if="scope.row.endTime<new Date()">已结束</el-tag>
           <el-tag type="success" v-else-if="scope.row.beginTime>new Date()">未开始</el-tag>
           <el-tag type="danger" v-else-if="scope.row.beginTime<new Date() && scope.row.endTime>new Date()">进行中</el-tag>
         </template>
      </el-table-column>
      <el-table-column label="实际投票人数" align="center" prop="voteCount" />
      <!-- <el-table-column label="计划投票人数" align="center" prop="limitCount" /> -->
     
      <el-table-column label="评委" align="center" prop="importCount">
        <template slot-scope="scope">
          <el-tag type="" @click="getRefList(scope.row)">查看</el-tag>  
        </template>
      </el-table-column>
      <el-table-column label="被投票人数" align="center" prop="importCount" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>

       <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width"  width="180">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleImport(scope.row)"
                     v-hasPermi="['vote:info:update']">导入</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleCopy(scope.row)"
                     v-hasPermi="['vote:info:update']">复制</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                     v-hasPermi="['vote:info:update']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                     v-hasPermi="['vote:info:delete']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

    <!-- 对话框(添加 / 修改) -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-form-item label="投票名称" prop="voteName">
          <el-input v-model="form.voteName" placeholder="请输入投票名称" />
        </el-form-item>
        <el-form-item label="投票开始时间" prop="beginTime">
          <el-date-picker clearable v-model="form.beginTime" type="datetime" value-format="timestamp" placeholder="选择投票开始时间" />
        </el-form-item>
        <el-form-item label="投票结束时间" prop="endTime">
          <el-date-picker clearable v-model="form.endTime" type="datetime" value-format="timestamp" placeholder="选择投票结束时间" />
        </el-form-item>

        <el-form-item label="投票模式" prop="isScope">
            <el-radio v-model="form.voteMode" :label="1">投票模式</el-radio>
            <el-radio v-model="form.voteMode" :label="2">打分模式</el-radio>
        </el-form-item>


        <div v-if="form.voteMode==1">
          <el-form-item label="是否打分" prop="isScope">
              <el-radio v-model="form.isScope" :label="true">是</el-radio>
              <el-radio v-model="form.isScope" :label="false">否</el-radio>
          </el-form-item>
          <el-form-item v-if="form.isScope" label="同意最小分数" prop="agreeMinScope">
            <el-input-number :min="0" v-model="form.agreeMinScope" placeholder="同意最小分数" />
          </el-form-item>
          <el-form-item v-if="form.isScope" label="同意最大分数" prop="agreeMaxScope">
            <el-input-number :min="0" v-model="form.agreeMaxScope" placeholder="同意最大分数" />
          </el-form-item>
          <el-form-item v-if="form.isScope" label="不同意最小分数" prop="noagreeMinScope">
            <el-input-number :min="0" v-model="form.noagreeMinScope" placeholder="不同意最小分数" />
          </el-form-item>
          <el-form-item v-if="form.isScope" label="不同意最大分数" prop="noagreeMaxScope">
            <el-input-number :min="0" v-model="form.noagreeMaxScope" placeholder="不同意最大分数" />
          </el-form-item>
        </div>
       
        <el-form-item label="关联规则" prop="isQuote">
           <el-radio v-model="form.isQuote" :label="true">是</el-radio>
           <el-radio v-model="form.isQuote" :label="false">否</el-radio>
        </el-form-item>

        <el-form-item v-if="form.isQuote" label="投票名称" >
          <el-select
          style="width:180px;"
            v-model="form.quoteVoteId"
            filterable
            remote
            reserve-keyword
            placeholder="请输入关键词"
            :remote-method="remoteSelectMethod"
          >
            <el-option
              v-for="item in voteNameList"
              :key="item.id"
              :label="item.voteName"
              :value="item.id">
            </el-option>
          </el-select>
      </el-form-item>
       
      <el-form-item label="是否显示单位排名" prop="isUnitSort">
          <el-radio v-model="form.isUnitSort" :label="true">是</el-radio>
          <el-radio v-model="form.isUnitSort" :label="false">否</el-radio>
      </el-form-item>
        



        <el-row v-for="(item, index) in form.refList" :key="index">
           
            <el-col :span="11">
              <el-form-item  label="姓名" :prop="'refList.' + index + '.userId'" >
                  <el-select v-model="item.userId" filterable placeholder="请输入关键词" @focus="listUsers" @change="updateUserList($event,item,index)">

                  <el-option
                    v-for="user in userListCopy"
                    :disabled="user.disabled"
                    :key="user.nickname"
                    :label="user.nickname"
                    :value="user.id">
                  </el-option>
                </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="11">
                <el-form-item label="所属组"  :prop="'refList.' + index + '.groupName'">
                  <el-select v-model="item.groupName" filterable placeholder="请选择">
                    <el-option
                      v-for="group in groupNameList"
                      :key="group.id"
                      :label="group.name"
                      :value="group.id">
                    </el-option>
                  </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="2">
                <i @click="delSection(index)" class="el-icon-delete btn-delete" ></i>
            </el-col>
        </el-row>

        <el-row>
            <el-col :span="24" style="text-align: right;">
                <el-form-item label="" >
                    <el-button  @click="newSection()" type="primary" plain icon="el-icon-plus" style="display: block;width: 100%;">添加评委专家</el-button>
                </el-form-item>
            </el-col>
        </el-row>


        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>



    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport+'&voteId='+upload.voteId" :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>


    <el-dialog :title="confirmVoteInfo" :visible.sync="showSelectVote" width="800px" append-to-body>
      <el-table v-loading="loading" :data="userRefList" :row-class-name="tableRowClassName">
        <el-table-column label="评委" align="center" prop="userName" />
        <el-table-column label="所属组" align="center" prop="groupName" />
        <el-table-column label="评委" align="center" prop="userName2" />
        <el-table-column label="所属组" align="center" prop="groupName2" />
      </el-table>
      <div slot="footer" class="dialog-footer o-footer">
        <el-button @click="showSelectVote=false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="copyVoteInfo" :visible.sync="isCopy" width="800px" append-to-body>
      <el-form label-width="150px">
        <el-form-item label="投票名称">
          <el-input v-model="copyForm.voteName" placeholder="请输入投票名称" />
        </el-form-item>
        <el-form-item label="是否复制专家">
            <el-radio v-model="copyForm.copyVoter" :label="true">是</el-radio>
            <el-radio v-model="copyForm.copyVoter" :label="false">否</el-radio>
        </el-form-item>
        <el-form-item label="是否复制被投票人">
            <el-radio v-model="copyForm.copyBeVoter" :label="true">是</el-radio>
            <el-radio v-model="copyForm.copyBeVoter"  :label="false">否</el-radio>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="copy">复 制</el-button>
        <el-button @click="isCopy = false">取 消</el-button>
      </div>
    </el-dialog>



  </div>
</template>

<script>
import { createInfo, updateInfo, deleteInfo, getInfo, getInfoPage, exportInfoExcel,getVoteName,copyVote } from "@/api/vote/info";
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
import {listSimpleUsers,listByName} from "@/api/system/user";
import {importTemplate,getUserRefList} from "@/api/vote/userRef";
import {getBaseHeader} from "@/utils/request";
export default {
  name: "Info",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 投票规则列表
      list: [],
      // 弹出层标题
      title: "",
      // 投票名称
      voteNameList: [],
      // 用户列表
      userList: [],   
      // 用户列表
      userListCopy: [],
      
      // 是否显示弹出层
      open: false,

      // 弹出层标题
      confirmVoteInfo: '评委信息预览',
      // 是否已投票
      userIsVoted: false,

      showSelectVote: false,


      voteNameList: [],

      // 是否复制
      copyVoteInfo: '复制投票信息',
      
      isCopy: false,

      copyForm:{
        copyVoter:false,
        copyBeVoter:false
      },

      // 
      userRefList: [],
      // 是否禁用voteType
      disabledVoteType: false,
      dateRangeBeginTime: [],
      dateRangeEndTime: [],
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        voteName: null,
        voteCount: null,
        limitCount: null,
        remark: null,
        voteType: 1
      },
      // 表单参数
      form: {
        // 动态表单
        refList: [{userName:'',groupName:''}],
        delList: [],
      },

      // 组名
      groupNameList: [
      {id:"总组",name:"总组"},
      {id:"青年通道组",name:"青年通道组"},
      {id:"基础与应用基础研究组",name:"基础与应用基础研究组"},
      {id:"应用技术研发组（正高）",name:"应用技术研发组（正高）"},
      {id:"应用技术研发组（副高）",name:"应用技术研发组（副高）"},
      {id:"成果转化、检验检测、实验技术、大田试验组",name:"成果转化、检验检测、实验技术、大田试验组"},
      {id:"科研管理、信息软科学研究组",name:"科研管理、信息软科学研究组"},
      ],

      //用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 投票id
        voteId: null,
        // 设置上传的请求头部
        headers: getBaseHeader(),
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + '/admin-api/vote/user-ref/import'
      },
      // 表单校验
      rules: {
        voteName: [
          { required: true, message: "投票名称不能为空", trigger: "blur" }
        ],
        isQuote: [
          { required: true, message: "是否引用其他投票规则用户信息不能为空", trigger: "blur" }
        ],
        beginTime: [
          { required: true, message: "投票开始时间不能为空", trigger: "blur" }
        ],
        endTime: [
          { required: true, message: "投票结束时间不能为空", trigger: "blur" }
        ],
      },
      voteTypeDictDatas: getDictDatas(DICT_TYPE.VOTE_RULE_TYPE),
    };
  },
  created() {
    this.getList();
    this.listUsers();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
      this.addBeginAndEndTime(params, this.dateRangeBeginTime, 'beginTime');
      this.addBeginAndEndTime(params, this.dateRangeEndTime, 'endTime');
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行查询
      getInfoPage(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },




    remoteSelectMethod(query){
      let params = {
        voteName: query,
        voteType: this.queryParams.voteType,
        pageSize: 50,
        pageNo: 1
      };
      getVoteName(params).then(response => {
        this.voteNameList = response.data;
      });
    },

    remoteGetUser(query){
      let params = {
        name: query
      };
      listByName(params).then(response => {
        this.userList = response.data;
      });
    },

    


    newSection () {
      this.form.refList.push({
        userId: '',
        groupName: ''
      })
    },
    delSection (index) {
      if(this.form.delList==undefined){
        this.form.delList=[];
      }
      let delItem = this.form.refList.splice(index, 1);
      this.form.delList.push(delItem[0].id);
      // this.updateUserList();
    },


    listUsers(){
      this.userListCopy = [];
      listSimpleUsers().then(resp=>{
        this.userList = resp.data;
        for(let user of resp.data){
          let item={id:user.id,nickname:user.nickname,userName:user.userName};
          
          for(let userRef of this.form.refList){
            if(userRef.userId == user.id){
              item.disabled = true;
            }
          }

          this.userListCopy.push(item);
         
        }

       


      })
    },

    updateUserList( val,item,index){
      this.userListCopy = [];
      for(let user of this.userList){
          let item={id:user.id,nickname:user.nickname,userName:user.userName};
          
          for(let userRef of this.form.refList){
            if(userRef.userId == user.id){
              item.disabled = true;
            }
          }
          this.userListCopy.push(item);
        }

      // this.form.refList[index].userId = null;
      // for(let userRef of this.form.refList){
      //   if(userRef.userId == val){
      //     this.$modal.msgSuccess("当前用户已存在,请重新选择！");
      //     return false;
      //   }
      // }
      // this.form.refList[index].userId = val;
    },



    tableRowClassName({row, rowIndex}) {
      if (rowIndex === 1) {
        return 'warning-row';
      } else if (rowIndex === 3) {
        return 'success-row';
      }
      return '';
    },

    getRefList(row){
      this.userRefList=[]
      this.showSelectVote=true;
      getUserRefList({voteId:row.id}).then(response => {
        console.log(response)
        for(let i=0;i<response.data.length;i=i+2){
          if(response.data[i]== undefined){
            break;
          }
          let data = {};
          data = response.data[i];
          if(response.data[i+1]!= undefined){
            data.userName2 = response.data[i+1].userName;
            data.groupName2 = response.data[i+1].groupName;
          }
          this.userRefList.push(data);
        }
      })
    },




    /** 导入按钮操作 */
    handleImport(row) {
      this.upload.title = "用户导入";
      this.upload.open = true;
      this.upload.voteId = row.id; 
    },



    copy(){
      if(this.copyForm.voteName=='' || this.copyForm.voteName==null){
        this.$modal.msgError("投票名称不能为空");
        return;
      }
      copyVote(this.copyForm).then(resp=>{
        this.$message({
          type: 'success',
          message: '复制成功!'
        });
        this.isCopy=false;
        this.getList();
      }).catch(() => {
        this.loading = false;
      });
    },

    handleCopy(row){
      this.copyForm={copyVoter:false,copyBeVoter:false};
      this.copyForm.id = row.id;
      this.isCopy=true;
      this.copyVoteInfo='复制"'+row.voteName+'"的投票规则';
      // this.$confirm('是否确认复制"'+row.voteName+'"投票规则?', '提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning'
      //   }).then(() => {
      //     this.loading = true;
      //     copyVote({id:row.id}).then(resp=>{
      //       this.$message({
      //         type: 'success',
      //         message: '复制成功!'
      //       });
      //       this.getList();
      //     }).catch(() => {
      //       this.loading = false;
      //     });
      //   });
    },

    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      if (response.code !== 0) {
        this.$modal.msgError(response.msg)
        return;
      }
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      // 拼接提示语
      let data = response.data;
      let text = '创建成功数量：' + data.createUsernames.length;
      // for (const username of data.createUsernames) {
      //   text += '<br />&nbsp;&nbsp;&nbsp;&nbsp;' + username;
      // }
      text += '<br />更新成功数量：' + data.updateUsernames.length;
      // for (const username of data.updateUsernames) {
      //   text += '<br />&nbsp;&nbsp;&nbsp;&nbsp;' + username;
      // }
      text += '<br />更新失败数量：' + Object.keys(data.failureUsernames).length;
      for (const username in data.failureUsernames) {
        text += '<br />&nbsp;&nbsp;&nbsp;&nbsp;' + username + '：' + data.failureUsernames[username];
      }
      this.$alert(text, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },

     /** 下载模板操作 */
     importTemplate() {
      importTemplate().then(response => {
        this.$download.excel(response, '评审导入模板.xls');
      });
    },


    getVote() {
      let params = {};
      params.voteType = 1;
      params.pageSize = 50;
      getVoteName(params).then(response => {
        this.voteNameList = response.data;
        this.voteNameList.map((item,index)=>{
          if(item.id==this.form.id){
            this.voteNameList.splice(index,1)
          }
        })
      });
    },

    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        voteName: undefined,
        beginTime: undefined,
        endTime: undefined,
        voteCount: undefined,
        limitCount: undefined,
        remark: undefined,
        importCount: undefined,
        quoteVoteId: undefined,
        isQuote: false,
        voteType: 1,
        refList: [{userName:'',groupName:''}],
        delList: [],
      };
      this.disabledVoteType =false;
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeBeginTime = [];
      this.dateRangeEndTime = [];
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加投票规则";
      this.getVote();
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.disabledVoteType=true;
      const id = row.id;
      getInfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改投票规则";
        this.getVote();
        // this.updateUserList();
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }

        for(let userRef of this.form.refList){
          if(userRef.userId == null){
            this.$modal.msgSuccess("姓名不能为空！");
            return false;
          }
        }


        // 修改的提交
        if (this.form.id != null) {
          updateInfo(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        createInfo(this.form).then(response => {
          this.$modal.msgSuccess("新增成功");
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
      this.$modal.confirm('是否确认删除投票规则编号为"' + id + '"的数据项?').then(function() {
          return deleteInfo(id);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
    },

    // remoteSelectMethod(query){
    //   let params = {
    //     voteName: query,
    //     voteType: this.queryParams.voteType,
    //     pageSize: 50,
    //     pageNo: 1
    //   };
    //   getVoteName(params).then(response => {
    //     this.voteNameList = response.data;
    //   });
    // },

    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.addBeginAndEndTime(params, this.dateRangeBeginTime, 'beginTime');
      this.addBeginAndEndTime(params, this.dateRangeEndTime, 'endTime');
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行导出
      this.$modal.confirm('是否确认导出所有投票规则数据项?').then(() => {
          this.exportLoading = true;
          return exportInfoExcel(params);
        }).then(response => {
          this.$download.excel(response, '投票规则.xls');
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
